package com.dqhl.community.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.model.SelectGoods;
import com.dqhl.community.util.ViewHolder;

import java.util.List;

/**
 * Created by cheng on 2016/9/11.
 * 商品类型adapter，选择商品的一级目录adapter
 */
public class GoodsSelectSubListAdapter extends BaseAdapter {

    private Context context;
    private LayoutInflater inflater;
    private int root_position; //父级的位置
    private List<SelectGoods> selectGoodsList;

    public GoodsSelectSubListAdapter(Context context, List<SelectGoods> selectGoodsList, int root_position) {
        this.context = context;
        this.selectGoodsList = selectGoodsList;
        this.inflater = LayoutInflater.from(context);
        this.root_position = root_position;
    }

    @Override
    public int getCount() {
        return selectGoodsList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = inflater.inflate(R.layout.lv_item_select_goods, viewGroup, false);
        }
        TextView tv_item_name = ViewHolder.get(view, R.id.tv_item_name);

        SelectGoods selectGoods = selectGoodsList.get(i);

        tv_item_name.setText(selectGoods.getName());

        return view;
    }
}
